from network import QNetwork
from generate import GenerateNetwork

import numpy as np

import math
# # def sliding_matrix(input_matrix):
# #     result_matrix = np.copy(input_matrix)
# #     result_matrix[:-1] = input_matrix[1:]
# #     result_matrix[-1] = 0
# #     return result_matrix

# def sliding_matrix(input_matrix):
#     result_matrix = np.copy(input_matrix)
#     result_matrix[:-1] = input_matrix[1:]
#     result_matrix[-1] = 0

#     input_matrix = result_matrix

# # 创建一个示例输入矩阵
# input_matrix = np.array([[1, 2, 3, 4],
#                          [5, 6, 7, 8],
#                          [9, 10, 11, 12],
#                          [13, 14, 15, 16]])

# # 创建滑动矩阵
# # slided_matrix = sliding_matrix(input_matrix)
# sliding_matrix(input_matrix)

# # 打印滑动矩阵的内容
# print("滑动矩阵：")
# print(input_matrix)


# data = [[17, 19], [17, 13], [8, 11], [20, 8], [13, 4], [2, 12], [20, 12], [8, 9], [14, 1], [16, 9], [11, 10], [6, 8], [11, 2], [1, 13], [17, 2], [20, 4], [16, 9], [20, 16], [16, 11], [8, 3], [10, 11], [14, 8], [10, 12], [6, 3], [15, 18], [10, 6], [17, 2], [17, 19], [14, 2], [9, 3]]

# # 创建一个空列表来存储重复元素
# duplicate_elements = []

# # 创建一个集合来存储已经出现过的元组
# seen = set()

# for item in data:
#     # 将元组按照升序排序
#     sorted_item = tuple(sorted(item))
    
#     if sorted_item in seen:
#         # 如果已经出现过，则加入重复元素列表
#         duplicate_elements.append(item)
#     else:
#         seen.add(sorted_item)

# # 输出重复元素
# print("重复元素：")
# for duplicate in duplicate_elements:
#     print(duplicate)


# import numpy as np

# # 将矩阵转换为字符串
# def matrix_to_str(matrix):
#     return matrix.tostring()

# # 将字符串转换为矩阵
# def str_to_matrix(string, shape, dtype=int):
#     return np.frombuffer(string, dtype=dtype).reshape(shape)

# # 示例用法
# matrix = np.array([[1, 2, 3], [4, 5, 6]])
# string_representation = matrix_to_str(matrix)
# print("String representation:", string_representation)

# reshaped_matrix = str_to_matrix(string_representation, shape=matrix.shape)
# print("Reshaped matrix:\n", reshaped_matrix)



# import matplotlib.pyplot as plt



# # 准备实验数据（示例）
# x = [1, 2, 3, 4, 5]
# y1 = [10, 25, 40, 25, 30]
# y2 = [5, 1, 15, 90, 25]

# # 绘制折线图
# plt.plot(x, y1, label='alg1')  # 绘制第一条曲线，并添加标签
# plt.plot(x, y2, label='alg2')  # 绘制第二条曲线，并添加标签
# plt.xlabel('X_index')
# plt.ylabel('Y_index')
# plt.title('throughput')

# # 添加图例
# plt.legend()

# # 保存图表为图片文件
# plt.savefig('experiment_plot.png')

# # 显示图表
# plt.show()



# 准备实验数据（示例）
# x = [1, 2, 3, 4, 5]
# y1 = [10, 15, 20, 25, 30]
# y2 = [5, 10, 15, 20, 25]

# # 将数据写入文件
# with open('experiment_data.txt', 'w') as f:
#     f.write('x,y1,y2\n')  # 写入列名
#     for i in range(len(x)):
#         f.write(f'{x[i]},{y1[i]},{y2[i]}\n')  # 写入数据

# print("实验数据已保存到 experiment_data.txt 文件中")

# import matplotlib.pyplot as plt

# # 读取实验数据
# x = []
# y1 = []
# y2 = []

# with open('experiment_data.txt', 'r') as f:
#     next(f)  # 跳过列名
#     for line in f:
#         data = line.strip().split(',')
#         x.append(int(data[0]))
#         y1.append(int(data[1]))
#         y2.append(int(data[2]))

# # 绘制折线图
# plt.plot(x, y1, label='alg1')  # 绘制第一条曲线，并添加标签
# plt.plot(x, y2, label='alg2')  # 绘制第二条曲线，并添加标签
# plt.xlabel('X_index')
# plt.ylabel('Y_index')
# plt.title('throughput')

# # 添加图例
# plt.legend()

# # 保存图表为图片文件
# plt.savefig('experiment_plot.png')

# # 显示图表
# plt.show()

import pandas as pd
import math

list = []
for i in range(30):
    list.append(i+1)

data = []
for day in range(30):
    day += 1
    counter = 0
    for i in range(day):
        counter += list[i]
    total_amount = math.ceil(counter/10) * 10
    data.append([day, total_amount])

# 创建DataFrame
df = pd.DataFrame(data, columns=['天数', '打卡总金额'])

# 将数据写入Excel文件
df.to_excel('/home/quantum/Desktop/wyy/CoalitionGamePy/打卡总金额.xlsx', index=False)

